<template>
    <div>
        <van-cell title="搜索历史">
            <template #default>
                <div v-if="isDeteleShow"> 
                <span>全部删除</span>
                <span @click="isDeteleShow = false">完成</span>
            </div>
                <van-icon name="delete" v-else @click="isDeteleShow = true"></van-icon>
            </template>
        </van-cell>
  <van-cell v-for="(item, index) in historys" :key="index" :title="item" @click="cellClick(index, item)">
  <template #default>
    <van-icon name="close" v-if="isDeteleShow"></van-icon>
  </template>
  </van-cell>
    </div>
    </template>

<script setup>
import { useUsersStore3 } from "../../store/search"
import { storeToRefs } from "pinia"
import { reactive, toRefs } from "vue"

let store = useUsersStore3()
let { historys } = storeToRefs(store)
let ress = reactive({
    isDeteleShow: false,
    pafeNum: 1
})
let { isDeteleShow } = toRefs(ress)

//点击历史记录
function cellClick(index, val) {

    if (ress.isDeteleShow) {
        //在删除状态
        store.historys.splice(index, 1)
    } else {
        //在未删除状态
        store.onSearch1(val)
    }
}
</script>

<style>

</style>